<?php
	
require '../include/user_login.inc.php';
require '../include/paging.inc.php';

	
if($_SESSION['ACCESS_SID'] != 2) redirect(HTML_BASE);

$redirect = $_SERVER['HTTP_REFERER'];	
$user_id = $_SESSION['USER_SID'];

$sql = "SELECT
			u.user_id,
			u.full_name,
			u.email
		FROM
			users AS u,
			law_users AS l
		WHERE
			l.law_id = '$user_id'
			AND
			u.user_id = l.use_id
			
		";


if (!isset($_GET['sort'])) $_GET['sort'] = 1;
if (!isset($_GET['sortBy'])) $_GET['sortBy'] = 2;

$paging = new Paging($sql, $_GET['sortBy'], $_GET['sort'], array(2=>"Подредба"), 30);
$result = $paging->query();
	
	head('Users');
	if($_SESSION['ACCESS_SID'] == 2) menu_law();

?>

<div id="content">

			<?php if ($_SESSION['message']) { ?>
			<div class="message green">
				<?=$_SESSION['message']?>
			</div>
			<?php unset($_SESSION['message']); } ?>
			
	

            <h3>Клиенти (<?=$paging->count() ?>)</h3>
            
            <table id="listing" width="100%" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
                
					<td>Име</td>
                    
					<td>e-mail</td>
                    
					
				</tr>
			</thead>
			<tbody>
			<?php
			  
			  
			  $i=1;
			  while ($row = mysql_fetch_object($result)) {				  
			?>
					<tr class="<?=(($i%2)?"none":"zebra")?>">
	
						<td><a href="<?=HTML_BASE.$_SESSION['lang']?>/user-history/<?=$row->user_id?>" title="Преглед"><?=sth($row->full_name)?></a></td>
						<td >
							<?=$row->email?>	
						</td>
						
						
					</tr>
         <?php
              $i++;    
            } 
         ?>				  
			</tbody>
		</table>
        
        <div class="pagingwrap"><div class="paging">
			<?=$paging->display()?>
		</div></div>
			
			
   </div>
    

<?php
foot();
?>